/*
 * Copyright (c) 2012 Supin P Surendran <supinps@gmail.com>.
 *
 * This file is part of InventoryMan.
 *
 * InventoryMan is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * InventoryMan is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with licenseTest.  If not, see <http ://www.gnu.org/licenses/>.
 *
 */
package InventoryMan;

import java.awt.event.ActionEvent;
import javax.swing.event.TableModelEvent;

/**
 *
 * @author supinps
 */
public class IndentNew extends javax.swing.JInternalFrame {

    /** Creates new form IndentNew
     * @param conn connection to database passed from the main window
     */
    @SuppressWarnings("static-access")
    public IndentNew(java.sql.Connection conn) {
        /**
         * set false initially
         * set true after fetching the new indent number
         * used for checking condition for save or generate indent number
         */
        save=false;
        imConnection=conn;
        comboData=new javax.swing.DefaultComboBoxModel();
        comboItem=new javax.swing.JComboBox();
        comboItemData=new javax.swing.DefaultComboBoxModel();
        itemCodes=new java.util.LinkedList<Object>();
        initComponents();
        initDataSet();
        initTable();
        initComboItemListener();
        initTableListener();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        TxtIndentNo = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        TxtCustId = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        CurDate = new org.jdesktop.swingx.JXDatePicker();
        DueDate = new org.jdesktop.swingx.JXDatePicker();
        jLabel5 = new javax.swing.JLabel();
        CmbName = new org.jdesktop.swingx.JXComboBox();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        TxtAddress = new javax.swing.JTextArea();
        jLabel7 = new javax.swing.JLabel();
        TxtOrderNo = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        OrderDate = new org.jdesktop.swingx.JXDatePicker();
        jScrollPane1 = new javax.swing.JScrollPane();
        TblItem = new javax.swing.JTable();
        BnOk = new javax.swing.JButton();
        BnCancel = new javax.swing.JButton();
        TxtTotal = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();

        setTitle("New Indent");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/icon_small.png"))); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Indent No :");

        jLabel2.setText("Customer Id :");

        TxtCustId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtCustIdActionPerformed(evt);
            }
        });

        jLabel3.setText("Indent Date :");

        jLabel4.setText("Due Date :");

        CurDate.setDate(new java.util.Date());

        DueDate.setDate(new java.util.Date());

        jLabel5.setText("Customer Name :");

        CmbName.setModel(comboData);
        CmbName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbNameActionPerformed(evt);
            }
        });

        jLabel6.setText("Custmer Address :");

        TxtAddress.setColumns(20);
        TxtAddress.setRows(5);
        jScrollPane2.setViewportView(TxtAddress);

        jLabel7.setText("Order No :");

        TxtOrderNo.setText("0");

        jLabel8.setText("Order Date :");

        OrderDate.setDate(new java.util.Date());

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2)
                    .addComponent(TxtCustId)
                    .addComponent(CmbName, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE))
                .addGap(181, 181, 181)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(OrderDate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(TxtOrderNo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
                        .addGap(25, 25, 25)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(DueDate, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(TxtIndentNo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(CurDate, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(TxtCustId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(CmbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(19, 19, 19)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(TxtOrderNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(TxtIndentNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(20, 20, 20)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(OrderDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DueDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(CurDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        TblItem.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Sl.No", "Item", "Remarks", "Area", "Quantity", "Rate", "Amount"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, true, true, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        TblItem.setCellSelectionEnabled(true);
        TblItem.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(TblItem);

        BnOk.setText("Generate Ind.");
        BnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BnOkActionPerformed(evt);
            }
        });

        BnCancel.setText("Cancel");
        BnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BnCancelActionPerformed(evt);
            }
        });

        jLabel9.setText("Total :");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 1169, Short.MAX_VALUE)
                            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(961, 961, 961)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addComponent(TxtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(961, Short.MAX_VALUE)
                        .addComponent(BnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(BnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(TxtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BnOk)
                    .addComponent(BnCancel))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BnCancelActionPerformed
        try {
            Stmt.execute("UNLOCK TABLES");
        }catch(java.sql.SQLException e) {}
        this.dispose();
    }//GEN-LAST:event_BnCancelActionPerformed

    private void CmbNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbNameActionPerformed
        try {
            replyCust.absolute(CmbName.getSelectedIndex()+1);
            TxtCustId.setText(Integer.toString(replyCust.getInt("code")));
            TxtAddress.setText(replyCust.getString("address"));
        }catch(java.sql.SQLException e){
            javax.swing.JOptionPane.showMessageDialog(this, "Communication Error\n"+e.toString());
        }
    }//GEN-LAST:event_CmbNameActionPerformed

    private void TxtCustIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtCustIdActionPerformed
        if(TxtCustId.isFocusOwner()) {
            try {
                replyCust.beforeFirst();
                while(replyCust.next()) {
                    if(replyCust.getInt("code")==Integer.parseInt(TxtCustId.getText())) {
                        comboData.setSelectedItem(replyCust.getString("name"));
                        TxtAddress.setText(replyCust.getString("address"));
                    }
                }
            }catch(java.sql.SQLException e) {
                javax.swing.JOptionPane.showMessageDialog(this, "Communication Error\n"+e.toString());
            }
        }
    }//GEN-LAST:event_TxtCustIdActionPerformed

    private void BnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BnOkActionPerformed
        if(tableData.getRowCount()>=2) {
        try {
            //Saving indent_entry
            if(!save) {
                Stmt.execute("LOCK TABLES indent_entry WRITE");
                replyCust.absolute(CmbName.getSelectedIndex()+1);
                replyIndent=Stmt.executeQuery("SELECT MAX(id) FROM indent_entry");
                replyIndent.next();
                new_id=replyIndent.getInt("MAX(id)")+1;
                TxtIndentNo.setText(Integer.toString(new_id));
                save=!save;
                BnOk.setText("Save");  
            }
            else {
                prepStmt=imConnection.prepareStatement("INSERT INTO indent_entry VALUES(?,?,?,?,?,?)");
                prepStmt.setInt(1, Integer.parseInt(TxtIndentNo.getText()));
                prepStmt.setDate(2, new java.sql.Date(CurDate.getDate().getTime()));
                prepStmt.setDate(3, new java.sql.Date(DueDate.getDate().getTime()));
                prepStmt.setInt(4, replyCust.getInt("code"));
                prepStmt.setDate(5, new java.sql.Date(OrderDate.getDate().getTime()));
                prepStmt.setInt(6, Integer.parseInt(TxtOrderNo.getText()));
                prepStmt.executeUpdate();
                Stmt.execute("UNLOCK TABLES");
                //Saving indent_items
                for(int i=0;i<tableData.getRowCount()-1;i++) {
                    prepStmt=imConnection.prepareStatement("INSERT INTO indent_item VALUES(?,?,?,?,?,?,?)");
                    prepStmt.setInt(1, Integer.parseInt(TxtIndentNo.getText()));
                    prepStmt.setInt(2,Integer.parseInt(tableData.getValueAt(i, 0).toString()));
                    prepStmt.setInt(3, Integer.parseInt(itemCodes.get(i).toString()));
                    prepStmt.setInt(4, Integer.parseInt(tableData.getValueAt(i, 4).toString()));
                    prepStmt.setInt(5, Integer.parseInt(tableData.getValueAt(i, 6).toString()));
                    prepStmt.setString(6, tableData.getValueAt(i, 2).toString());
                    prepStmt.setInt(7, 0);
                    prepStmt.executeUpdate();
                }
                save=!save;
                this.dispose();
            }
        }catch(java.sql.SQLException e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Communication Error\n"+e.toString());
        }
        }
        else {
            javax.swing.JOptionPane.showMessageDialog(this, "No Items Entered");
        }
    }//GEN-LAST:event_BnOkActionPerformed

    /**
     * Fetches the initial Data to populate form fields especially ComboBoxes
     * from the Database and populates the Respective Fields
     */
    private void initDataSet() {
        try {
            Stmt=imConnection.createStatement();
            replyCust=Stmt.executeQuery("SELECT * FROM customer");
            while(replyCust.next()) {
                comboData.addElement(replyCust.getString("name"));
            }
        }catch(java.sql.SQLException e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Communication Error\n"+e.toString());
            this.dispose();
        }
    }

    private void initTable() {
        initComboItem();
        tableData=new javax.swing.table.DefaultTableModel(new Object[]{"Sl. No.","Item","Remarks","Area","Quantity","Rate","Amount"}, 0);
        TblItem.setModel(tableData);
        TblItem.getColumnModel().getColumn(1).setCellEditor(new javax.swing.DefaultCellEditor(comboItem));
        tableData.addRow(new Object[]{});//Adding a blank row
        rowIndex=tableData.getRowCount()-1;//Finding current row index, which starts at index 0
        tableData.setValueAt(rowIndex+1, rowIndex, 0);//Inserting slNo:rowIndex+1,to first column:0 of the current row:rowIndex
    }
    private void initComboItem() {
        comboItem.setModel(comboItemData);
        try {
            Stmt=imConnection.createStatement();
            replyItem=Stmt.executeQuery("SELECT * FROM item");
            while(replyItem.next()) {
                comboItemData.addElement(replyItem.getString("name"));
            }
        }catch(java.sql.SQLException e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Communication Error\n"+e.toString());
        }
    }
    private void initComboItemListener() {
        comboItem.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(ActionEvent e) {
                try {
                    replyItem.absolute(comboItem.getSelectedIndex()+1);
                    int area=replyItem.getInt("width")*replyItem.getInt("length");
                    int rate=replyItem.getInt("rate");
                    tableData.setValueAt(area, rowIndex, 3);
                    tableData.setValueAt(rate, rowIndex, 5);
                    tableData.setValueAt("", rowIndex, 2);
                    //save the chosen itemcode to the index corresponding to table index
                    itemCodes.add(rowIndex, replyItem.getInt("code"));
                }catch(java.sql.SQLException ex) {
                }
            }
        });
    }
    private void initTableListener() {
        TblItem.getModel().addTableModelListener(new javax.swing.event.TableModelListener() {

            public void tableChanged(TableModelEvent e) {
                if(e.getType()==javax.swing.event.TableModelEvent.UPDATE) {
                    boolean flag=true;
                    for(int i=0;i<tableData.getColumnCount()-1;i++) {
                        Object val=tableData.getValueAt(rowIndex, i);
                        if(val!=null&&i==4) {
                           /*
                            * Disabling TableModelListener temporarily
                            * For Programmatically  Updating the table
                            */
                           TblItem.getModel().removeTableModelListener(this);
                           int quantity=Integer.parseInt(tableData.getValueAt(rowIndex, 4).toString());
                           int rate=Integer.parseInt(tableData.getValueAt(rowIndex, 5).toString());
                           tableData.setValueAt(quantity*rate, rowIndex, 6);
                           TblItem.getModel().addTableModelListener(this);
                        }
                        if(i!=2) {
                            if(val==null) {
                                flag=false;
                            }
                        }
                    }
                    if(flag) {
                        int total=0;
                        for(int i=0;i<=rowIndex;i++) {
                            total=total+Integer.parseInt(tableData.getValueAt(i, 6).toString());
                            TxtTotal.setText(Integer.toString(total));
                        }
                        tableData.addRow(new Object[]{});
                        rowIndex++;
                        tableData.setValueAt(rowIndex+1, rowIndex, 0);
                    }
                }
            }
        });
    }
    //End of Method Definitions

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BnCancel;
    private javax.swing.JButton BnOk;
    private org.jdesktop.swingx.JXComboBox CmbName;
    private org.jdesktop.swingx.JXDatePicker CurDate;
    private org.jdesktop.swingx.JXDatePicker DueDate;
    private org.jdesktop.swingx.JXDatePicker OrderDate;
    private javax.swing.JTable TblItem;
    private javax.swing.JTextArea TxtAddress;
    private javax.swing.JTextField TxtCustId;
    private javax.swing.JTextField TxtIndentNo;
    private javax.swing.JTextField TxtOrderNo;
    private javax.swing.JTextField TxtTotal;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables

    //Manually Declared Variables
    java.sql.Connection imConnection;
    java.sql.Statement Stmt;
    java.sql.ResultSet replyCust;
    java.sql.ResultSet replyItem;
    java.sql.ResultSet replyIndent;
    java.sql.PreparedStatement prepStmt;
    //Table and ComboBox Model, to hold the Data to be displayed
    javax.swing.table.DefaultTableModel tableData;
    //Save button
    boolean save;
    int rowIndex;
    int new_id;
    java.util.List<Object> itemCodes;
    javax.swing.DefaultComboBoxModel comboData;
    javax.swing.JComboBox comboItem;
    javax.swing.DefaultComboBoxModel comboItemData;
    //End of Declarations
}
